Vue.component('nav-component', {
    props: ['a_text1', 'a_text2'],
    template: '<ul class="leftnav fl"><li v-for="item in a_text2"><a target="_self" class="two" :href="item.FunctionUrl" :class="item.active" :data-value="item.FunctionID">{{item.FunctionName}}</a></li></ul>'
})
Vue.component('hrader-component', {
    props: ["text"],
    template: '<div><div class="top clearfix mt-10" ><p class="fl"> 北京华夏55科技有限公司欢迎您！</p><p class="fr"><a href="/BasicSettings/UpdatePwd" id="modifyPassword">修改密码</a> <a href="/Login/login" id="exit">退出登录</a></p></div><div class="topNav clearfix"><ul class="fr"><li v-for="item in text" class="fl"><a :class="item.active" href="javascript:;" :data-value="item.FunctionID" v-text="item.FunctionName"></a></li></ul></div></div>'
})
Vue.component('pagination-component', {
    props: ["Count","currentIndex", "pageSizes","pageSize"],
    computed: {
        getMaxMin: function () {
            var max = 1;
            var min = 1;
            var liNums;
            var totalCount = parseInt(this.Count);
            var currentIndex = parseInt(this.currentIndex);
            var max = totalCount;
            var min = 1;
            if (totalCount >= 10) {
                if (currentIndex >= totalCount - 4) {
                    max = totalCount;
                    min = parseInt(totalCount) - 9;
                } else if (parseInt(currentIndex) < 7) {
                    max = 10;
                    min = 1;
                } else if (currentIndex >= 7 && currentIndex < totalCount) {
                    min = currentIndex - 5;
                    max = currentIndex + 4;
                } else {
                    min = 1;
                    max = 10;
                }
            } else {
                min = 1;
                max = totalCount;
            }
            liNums = max - min + 1;
            return { max: max, min: min, liNums: liNums}
        }
    },
    template:
    '<div>'
        + '<p class="empty_block" v-if="!Count">暂无数据</p>'
        +'<div class="Pagination clearfix">'
            + '<div class="form-group fl" >'
                + '<select class="form-control" id="page">'
                    + '<option v-for="item in pageSizes" :value="item" :selected="item==pageSize">{{item}}条 / 页</option>'
                + '</select>'
            + '</div>'
            + '<nav style="text-align: center;" class="fl" aria-label="Page navigation" v-if="Count">'
                + '<p class="fl lh-34" style="margin-left:10px"> 共 <span > {{ Count }}</span > 页</p >'
                + '<ul class="fl pagination" v-if="getMaxMin.max">'
                    + '<li class="fl first" v-bind:class="{ disabled: currentIndex==1}">'
                        + '<a href="javascript:;">首页</a>'
                    + '</li>'
                    + '<li class="fl" v-for="(n,index) in parseInt(getMaxMin.liNums)" v-bind:class="{ active: parseInt(getMaxMin.min)+index==currentIndex}">'
                        + '<a href="javascript:;"v-text="parseInt(getMaxMin.min)+index"></a>'
                    + '</li>'
                    + '<li class="fl last" v-bind:class="{ disabled: currentIndex==Count}">'
                        +'<a href="javascript:;" > 末页</a>'
                    +'</li>'
                + '</ul>'
                + '<p class="fl" >前往<input type= "text" class="form-control jumpPage" :value="currentIndex" id="jumpPage" />页</p>'  
            + '</nav>'
        + '</div >'
    +'</div>'
})    
var nav = new Vue({
    el: '#nav',
    data: {
        a_text1: [],
        a_text2: []
    }
})
var hrader = new Vue({
    el: '#header',
    data: {
        text: []
    }
})
var Pagination = new Vue({
    el: '#Pagination',
    data: {
        Count: "",
        current: "1",
        pageSizes: [10, 15, 30, 50,100,200,300,500],
        currentIndex: 1,
        jumpPage: this.currentIndex,
        pageSize: curPageSize = GetQueryStringH("PageSize") == null ? 10 : GetQueryStringH("PageSize")
    }
})
var menu = JSON.parse(localStorage.getItem('menu'));
var oneid = localStorage.getItem("oneid");
var twoid = localStorage.getItem("twoid");
$.each(menu, function (index,item) {
    if (item.ParentID == "00000000-0000-0000-0000-000000000000") {
        hrader.text.push(item);
    }
    hrader.text[index].active = "";
    if (item.FunctionID == oneid) {
        nav.a_text1 = [];
        nav.a_text2 = [];
        nav.a_text1.push(item);
        hrader.text[index].active = "active";
        nav.a_text2 = item.GetFunctionList;
        nav.a_text2[0].active = "active";
    }
    if (item.FunctionID == oneid && twoid) {
        nav.a_text1 = [];
        nav.a_text2 = [];
        nav.a_text1.push(item);
        nav.a_text2 = item.GetFunctionList;
        $.each(item.GetFunctionList, function (index1, item1) {
            nav.a_text2[index1].active = "";
            if (item1.FunctionID == twoid) {
                nav.a_text2[index1].active = "active";
            }
        })
        
    }
})
$(document).on("click", ".topNav ul a", function () {
    $(".topNav ul a").removeClass("active");
    $(this).addClass("active");
    var value = $(this).attr("data-value")
    localStorage.setItem("oneid", value);
    localStorage.setItem("twoid", "");
    $.each(menu, function (idnex, item) {
        if (item.FunctionID == value) {
            window.location.href = item.GetFunctionList[0].FunctionUrl;
        }
    })
})
$(document).on("click", "#nav .leftnav .two", function () {
    var value = $(this).attr("data-value");
    localStorage.setItem("twoid", value);
})
var arr = [];
var butFunction = JSON.parse(localStorage.getItem('butFunction'))
function showhide() {
    setTimeout(function () {
        if ($(".showHide").val()) {
            var parentcode = $(".showHide").val();
            $.each(butFunction, function (index, item) {
                if (item.ParentCode == parentcode) {
                    arr.push(item.FuctionCode);
                }
            })
            $.each($(".Jurisdiction"), function () {
                var _this = $(this)
                $.each(arr, function (index, item) {
                    if (item == _this.attr("data-show")) {
                        _this.css("display", "inline-block");
                    }
                })
            })
        }
    }, 200);
}
var functionOnOff = true;